<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>

<script>
    // regiser.html  => 注册页 => 点击提交数据到login.html
    // login.html  => 接收注册页传递的数据并解析   => 对象 {user:"a123123",pwd,phone,email}

    // 参数数据解析  => 本质:操作字符串 => 得到想要的数据
    console.log(location);

    var search = location.search;
    console.log("search",search);

    var data = {};

    if(search){  // 判断有没有数据
        var str = search.slice(1);
        console.log("str",str);
        var list = str.split("&");
        console.log("list",list);

        for(var i=0;i<list.length;i++){
            var item = list[i];  // 'user=zxczxc', 'pwd=123123', 
            var key = item.split("=")[0]; // "user"  "pwd"   将字符串作为对象的键名 => []
            var val = item.split("=")[1]; // 
            console.log(item,key,val);
            data[key] = val;
        }
        console.log(data);

    }else{  // 没有数据 => 去注册
        location.href = "./register.html";
    }







</script>
</html>